package org.cc.cstc.utils;

import org.cc.cstc.querystrategy.QueryStrategy;
import org.cc.cstc.querystrategy.impl.SqlQueryStrategy;
import org.cc.cstc.querystrategy.impl.TextQueryStrategy;

import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ClipBoardUtil {

    /**
     * 判断剪切板中是否有文字数据
     * @return
     */
    public static boolean checkClipboardForText(){
        //获取到系统剪切板
        Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        Transferable contents = systemClipboard.getContents(null);
        return contents != null && contents.isDataFlavorSupported(DataFlavor.stringFlavor);
    }

    /**
     * 获取剪切板内容
     * @return str
     */
    public static String getClipBoardContent() {
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        Transferable contents = clipboard.getContents(null);
        try{
            if(contents != null && contents.isDataFlavorSupported(DataFlavor.stringFlavor)){
                return (String) contents.getTransferData(DataFlavor.stringFlavor);
            }
        } catch (IOException | UnsupportedFlavorException e) {
           return "";
        }
        return "";
    }
}
